<template>
  <s-pull-scroll ref="pullScroll" :pullDown="pullDown">
	<view class="page-main">
    <view v-for="(item,i) in list" :key="i">
      <customerCard :item="item" :type="0" />
    </view>
    <uni-load-more v-show="showLoading" class="loadMore" :status="status" :icon-size="12" :content-text="contentText"/>
  
  </view>
  </s-pull-scroll>
</template>

<script>
  import customerCard from "@/components/customerCard.vue"
  import {loadMore} from "../../util/reuse/loadMore"
  
	export default {
    mixins: [loadMore],
		data() {
			return {
				list:[],
				showLoading: true,
			};
		},
    components:{customerCard},
    methods:{
      pullDown(){
        this.list=[];
				this.showLoading = false;
        this.getlist();
				
      },
      getlist(){
        this.$tokenRequest('/public_list').then(res=>{
          setTimeout(() => {
            this.showLoading = true;
            this.$refs.pullScroll.success();
          },500)
          this.status = 'noMore';
          this.list = res.data
        }).catch(()=>{
          this.status = 'noMore';
          this.showLoading = true;
          setTimeout(() => {
            this.$refs.pullScroll.success();
          },500)
        })
      //     uni.request({
      //     url:`${this.$http}/api/merchant/public_list`,
      //     method:"POST",
      //     header: {
      //       Authorization: 'Bearer ' + this.$store.state.token
      //     },
      //     success:(res)=>{
						// this.status = 'noMore';
						// this.showLoading = true;
      //       // console.log('res',res);
      //       if(res.data.code==200){
      //         setTimeout(() => {
      //           this.$refs.pullScroll.success();
      //         },500)
      //         this.list = res.data.data
      //       }else if(res.data.code == 402 || res.data.code == 506){
      //           setTimeout(()=>{
      //             this.$logout(res.data.msg);
      //           },1500)
      //         }else{
      //         setTimeout(() => {
      //           this.$refs.pullScroll.error();
      //         },500)
      //         uni.showToast({
      //           title: res.data.msg,
      //           position: 'top',
      //           icon: 'none',
      //           duration: 2000
      //         });
      //       }
      //     }
      //   })
      }
    },
    onShow() {
      this.getlist()
    }
	}
</script>

<style lang="scss" scoped>
  @import "../../assets/styles/global";
  
  .page-main{
    padding: 15px;
    background-color: $greyBackgroundColor;
    min-height: 100vh;
  }
</style>
